Adding, Removing Right Click Protection

Javascript right click protection scripts

Basic right click protection
For a very basic protection script, copy and paste the following code into the top of any web page anywhere between the <head> and </head> tags. This can be added to any .html page or the "slideshow.htm" or "image-viewer.htm".


<meta http-equiv="imagetoolbar" content="no">

<script type="text/javascript">
function noRightClick() {
if (event.button==2) {
alert('You may not right mouse click this page.')
}
}
document.onmousedown=noRightClick
</script>


Advanced right click protection
The following script includes more browser compatibility. Copy and paste the following code into the top of any web page anywhere between the <head> and </head> tags. This can be added to any .html page or the "slideshow.htm" or "image-viewer.htm".


<meta http-equiv="imagetoolbar" content="no">

<script type="text/javascript">
<!-- Begin
var message="You may not right mouse click this page.";
if (navigator.appName == 'Microsoft Internet Explorer'){
function NOclickIE(e) {
if (event.button == 2 || event.button == 3) {
alert(message);
return false;
}
return true;
}
document.onmousedown=NOclickIE;
document.onmouseup=NOclickIE;
window.onmousedown=NOclickIE;
window.onmouseup=NOclickIE;
}
else {
function NOclickNN(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=NOclickNN; }
document.oncontextmenu=new Function("alert(message);return false")
}
// End -->
</script>


Using the above scripts in a .js file
The scripts above can be added to a .js file like the "javascipts.js" so it can be globally added to all your webpages. To use the no right click script in a .js file, copy the above code, paste it into the bottom of your .js file and remove the following lines:

<meta http-equiv="imagetoolbar" content="no">

<script type="text/javascript">
<!-- Begin

..at the end remove these lines:

// End -->
</script>


To turn off right click protection
Your template may include a file named "right-click-protection.js". It may be located in the "slideshow" or "lytebox" folders. At the top of the file edit the "RIGHT CLICK PROTECTION ON" to yes or no to use, or not use the protection.

In some templates you may need to remove the script in the head section of your "slideshow.htm" or "image-viewer.htm".

Note: Be sure to make backups of your files before you start editing.



Responsive for Mobile Web Design




For older templates with popup gallery images.
To prevent right click in the pop-up windows. Edit the "pop-closeup.js" in Notepad and add these lines just before the <body bgcolor="# etc...>

popwin.document.write('<meta http-equiv="imagetoolbar" content="no">')
popwin.document.write('<script language="JavaScript">')
popwin.document.write('function noRightClick() {')
popwin.document.write('if (event.button==2) {')
popwin.document.write('alert(\'You may not right mouse click this page.\')')
popwin.document.write('}')
popwin.document.write('}')
popwin.document.write('document.onmousedown=noRightClick')
popwin.document.write('</script>')